using System;
using System.Drawing;
using System.Collections.Generic;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
using System.Linq;
using System.Collections;

namespace QLTV.Reports
{
    public partial class rptCrewCard : DevExpress.XtraReports.UI.XtraReport
    {
        public rptCrewCard()
        {
            InitializeComponent();

        }
        public rptCrewCard(string crewID)
        {
            InitializeComponent();
            bindData(crewID);
            detailCertificate.BeforePrint += bindSTT;
        }

        int stt = 0;
        string add;
        string addLienHe;
        QLTV.Database.dsReportTableAdapters.tblCrewTableAdapter tadCrew;
        public void bindData(string crewID)
        {
            cellDatePrepare.Text = DateTime.Now.Date.ToString("dd-MMM-yyyy");
            cellPrepareBy.Text = Program.EmployeeName;
            vesselDetailTableAdapter.Fill(dsVessel.vesselDetail);
            tadCrew = new Database.dsReportTableAdapters.tblCrewTableAdapter();
            
            tadCrew.FillBy(dsReport1.tblCrew, crewID);
            add = tadCrew.getDiaChi(crewID);
            addLienHe = tadCrew.DiaChiLienHe(crewID);
            tblExprienceTableAdapter.Fill(dsReport1.tblExprience, crewID);

            tblCertificateCrewTableAdapter.FillByCrewID(dsReport1.tblCertificateCrew, crewID);
            tblEducationTableAdapter.FillByCrewID(dsReport1.tblEducation, crewID);
            tblImmigrationCrewTableAdapter.FillByCrewID(dsReport1.tblImmigrationCrew, crewID);

        }

        public void bindSTT(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            stt++;
            colSTT.Text = stt.ToString();
        }

        private void xrLabel10_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            xrLabel10.Text = Ultilities.RemoveSign4VietnameseString(xrLabel10.Text);
        }

        private void xrLabel11_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            ((XRLabel)sender).Text = Ultilities.RemoveSign4VietnameseString(((XRLabel)sender).Text);
        }

        private void docExpiry_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            if (((XRLabel)sender).Text.Trim() == "")
            {
                ((XRLabel)sender).Text = "Unlimited";
            }
        }

        private void xrLabel13_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
           // if (((XRLabel)sender).Text.Trim() == "")
           // {
                ((XRLabel)sender).Text = "Vietnamese";
          //  }
        }

        private void address_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            if (add != null)
                ((XRLabel)sender).Text = Ultilities.RemoveSign4VietnameseString(add);
        }

        private void xrLabel32_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            if (addLienHe != null)
                ((XRLabel)sender).Text = Ultilities.RemoveSign4VietnameseString(addLienHe);
        }


    }

}
